import request from '@/utils/http'

export const userLogin = async ({ username, password }) => {
    return await request({
        url:'/users/account/login',
        method: 'POST',
        params: {
            username,
            password,
        }
    })
}

export const insertSearchRecord = async (keyword,userid) => {
    // alert(keyword)
    // alert(userid)
    // return request.put(`/users/account/newSearch?keyWord=${keyword}&userid=${userid}`);
    return await request({
        url:'/users/account/newSearch',
        method: 'PUT',
        params: {
            keyWord:keyword,
            userid:userid,
        }
    })
    // return await request.put('/users/account/newSearch', ,{
    //     params: {
    //         keyword:keyword,
    //         id:id,
    //     },
    // });
}

export const userRegister = async (user) => {
    return await request.post('/users/account/register',JSON.stringify(user),{
        headers:{
            'Content-Type' : 'application/json',
        },
    },
    )
}

export const changeUserInfo = async (id,user) => {
    return await request.put(`/users/account/user/info/${id}`, JSON.stringify(user), {
        headers: {
            'Content-Type': 'application/json',
        },
        params: {
            id: id,
        },
    });
}

export const userSearchRecord = async (userid) => {
    // return await request.get('/users/account/user/record',{
    //     params:{
    //         userid:userid,
    //     },
    // })
    return await request({
        url: '/users/account/user/record',
        method: 'GET',
        params:{
            userid:userid,
        },
    })
}
